/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FlowSimulatorPanel.java
 *
 * Created on 7-okt-2009, 19:54:48
 */

package gui;

import flowsimulation.FlowSimulator;
import flowvis.DensityRenderer;
import flowvis.VelocityRenderer;
import flowvis.ForceRenderer;
import flowvis.ColorMap;
import flowvis.ConeRenderer;
import flowvis.DivergenceRenderer;
import flowvis.EllipsoidRenderer;
import flowvis.HedgehogRenderer;
import flowvis.IsoLinesRenderer;

/**
 *
 * @author michel
 */
public class FlowSimulatorPanel extends javax.swing.JPanel {

    FlowSimulator simulator;

    /**
     * Constructor. Creates new form FlowSimulatorPanel
     * @param sim , initialized FlowSimulator.
     */
    public FlowSimulatorPanel(FlowSimulator sim) {
        initComponents();
        simulator = sim;
        viscosityTextfield.setText("" + simulator.getViscosity());
        timestepTextField.setText("" + simulator.getTimeStep());
        saturationTextField.setText("" + ColorMap.getSaturation());
        hueTextField.setText("" + ColorMap.getHue());
        densityButton.setSelected( true );
        velocityVector.setSelected( true );
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dataSetButtonGroup = new javax.swing.ButtonGroup();
        vectorSetButtonGroup = new javax.swing.ButtonGroup();
        runningCheckbox = new javax.swing.JCheckBox();
        viscosityTextfield = new javax.swing.JTextField();
        timestepTextField = new javax.swing.JTextField();
        viscosityLabel = new javax.swing.JLabel();
        timeStepLabel = new javax.swing.JLabel();
        timeStepSliderVariable = new javax.swing.JSlider();
        viscositySliderVariable = new javax.swing.JSlider();
        dataSetLabel = new javax.swing.JLabel();
        densityButton = new javax.swing.JRadioButton();
        velocityMButton = new javax.swing.JRadioButton();
        forceMagnitude = new javax.swing.JRadioButton();
        saturationSlider = new javax.swing.JSlider();
        saturationLabel = new javax.swing.JLabel();
        saturationTextField = new javax.swing.JTextField();
        hueTextField = new javax.swing.JTextField();
        hueLabel = new javax.swing.JLabel();
        hueSlider = new javax.swing.JSlider();
        vectorSet = new javax.swing.JLabel();
        velocityVector = new javax.swing.JRadioButton();
        forceVector = new javax.swing.JRadioButton();
        vectorSetCheckBox = new javax.swing.JCheckBox();
        glyphSet = new javax.swing.JComboBox();
        divergenceButton = new javax.swing.JRadioButton();
        isoLinesCheckBox = new javax.swing.JCheckBox();
        rho0TextField = new javax.swing.JTextField();
        isoline0Slider = new javax.swing.JSlider();
        jLabel1 = new javax.swing.JLabel();

        runningCheckbox.setSelected(true);
        runningCheckbox.setText("Running");
        runningCheckbox.setToolTipText("Start/stop simulation");
        runningCheckbox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                runningCheckboxActionPerformed(evt);
            }
        });

        viscosityTextfield.setEditable(false);

        timestepTextField.setEditable(false);

        viscosityLabel.setLabelFor(viscosityTextfield);
        viscosityLabel.setText("Viscosity:");

        timeStepLabel.setLabelFor(timestepTextField);
        timeStepLabel.setText("Time step:");
        timeStepLabel.setName("Time_Step"); // NOI18N

        timeStepSliderVariable.setToolTipText("Drag to change the time step");
        timeStepSliderVariable.setValue(40);
        timeStepSliderVariable.setName("Time_Step_Slide"); // NOI18N
        timeStepSliderVariable.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                timeStepSliderVariableMouseDragged(evt);
            }
        });

        viscositySliderVariable.setMinimum(1);
        viscositySliderVariable.setToolTipText("Drag to change the viscosity");
        viscositySliderVariable.setValue(1);
        viscositySliderVariable.setName("Viscosity_slide"); // NOI18N
        viscositySliderVariable.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                viscositySliderVariableMouseDragged(evt);
            }
        });

        dataSetLabel.setText("Data set:");

        dataSetButtonGroup.add(densityButton);
        densityButton.setText("Density");
        densityButton.setToolTipText("Choose as data set to visualize");
        densityButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                densityButtonActionPerformed(evt);
            }
        });

        dataSetButtonGroup.add(velocityMButton);
        velocityMButton.setText("Velocity magnitude");
        velocityMButton.setToolTipText("Choose as data set to visualize");
        velocityMButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                velocityMButtonActionPerformed(evt);
            }
        });

        dataSetButtonGroup.add(forceMagnitude);
        forceMagnitude.setText("Force magnitude");
        forceMagnitude.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                forceMagnitudeButtonActionPerformed(evt);
            }
        });

        saturationSlider.setToolTipText("Drag to change the value of the saturation");
        saturationSlider.setValue(0);
        saturationSlider.setName("saturationSlide"); // NOI18N
        saturationSlider.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                saturationSlider(evt);
            }
        });

        saturationLabel.setLabelFor(timestepTextField);
        saturationLabel.setText("Saturation :");
        saturationLabel.setName("Saturation"); // NOI18N

        saturationTextField.setEditable(false);
        saturationTextField.setName("saturationTextField"); // NOI18N

        hueTextField.setEditable(false);
        hueTextField.setName("hueTextField"); // NOI18N

        hueLabel.setLabelFor(timestepTextField);
        hueLabel.setText("Hue :");
        hueLabel.setName("Time_Step"); // NOI18N

        hueSlider.setMaximum(360);
        hueSlider.setToolTipText("Drag to change the value of the hue");
        hueSlider.setValue(0);
        hueSlider.setName("hueSlide"); // NOI18N
        hueSlider.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                hueSlider(evt);
            }
        });

        vectorSet.setText("Vector set:");

        vectorSetButtonGroup.add(velocityVector);
        velocityVector.setLabel("Velocity");
        velocityVector.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                velocityVectorActionPerformed(evt);
            }
        });

        vectorSetButtonGroup.add(forceVector);
        forceVector.setText("Force");
        forceVector.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                forceVectorActionPerformed(evt);
            }
        });

        vectorSetCheckBox.setText("Glyph");
        vectorSetCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vectorSetCheckBoxActionPerformed(evt);
            }
        });

        glyphSet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Hedgehog", "Ellipsoid", "Cone" }));
        glyphSet.setEnabled(false);
        glyphSet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                glyphSetActionPerformed(evt);
            }
        });

        dataSetButtonGroup.add(divergenceButton);
        divergenceButton.setText("Divergence");
        divergenceButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                divergenceButtonActionPerformed(evt);
            }
        });

        isoLinesCheckBox.setText("View isoline(s).");
        isoLinesCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                isoLinesCheckBoxActionPerformed(evt);
            }
        });

        rho0TextField.setEditable(false);
        rho0TextField.setText("0.0");

        isoline0Slider.setMaximum(100000);
        isoline0Slider.setValue(0);
        isoline0Slider.setEnabled(false);
        isoline0Slider.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                isoline0SliderMouseDragged(evt);
            }
        });

        jLabel1.setText("Rho 0:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(runningCheckbox)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(viscosityLabel)
                                    .addComponent(timeStepLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(viscosityTextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                                    .addComponent(timestepTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                                    .addComponent(viscositySliderVariable, 0, 0, Short.MAX_VALUE)
                                    .addComponent(timeStepSliderVariable, 0, 0, Short.MAX_VALUE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(dataSetLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(densityButton)
                            .addComponent(divergenceButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(forceMagnitude)
                            .addComponent(velocityMButton)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(vectorSet)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(forceVector)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(velocityVector)
                                        .addGap(18, 18, 18)
                                        .addComponent(vectorSetCheckBox)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(glyphSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(isoLinesCheckBox)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(isoline0Slider, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(rho0TextField, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(saturationLabel)
                            .addComponent(hueLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(hueSlider, 0, 0, Short.MAX_VALUE)
                            .addComponent(hueTextField)
                            .addComponent(saturationTextField)
                            .addComponent(saturationSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(57, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(runningCheckbox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(viscosityLabel)
                    .addComponent(viscosityTextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addComponent(viscositySliderVariable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(timestepTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(timeStepLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(timeStepSliderVariable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(densityButton)
                    .addComponent(dataSetLabel)
                    .addComponent(velocityMButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(forceMagnitude)
                    .addComponent(divergenceButton))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(vectorSet)
                        .addGap(27, 27, 27))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(velocityVector)
                            .addComponent(vectorSetCheckBox)
                            .addComponent(glyphSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(forceVector)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(isoLinesCheckBox)
                    .addComponent(jLabel1)
                    .addComponent(rho0TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(isoline0Slider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(saturationLabel)
                    .addComponent(saturationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(saturationSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(hueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(hueLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(hueSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(49, 49, 49))
        );

        timeStepSliderVariable.getAccessibleContext().setAccessibleDescription("");
        viscositySliderVariable.getAccessibleContext().setAccessibleDescription("");
        dataSetLabel.getAccessibleContext().setAccessibleName("Data set");
        forceMagnitude.getAccessibleContext().setAccessibleDescription("Choose as data set to visualize");

        getAccessibleContext().setAccessibleParent(getRootPane());
    }// </editor-fold>//GEN-END:initComponents

    private void runningCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runningCheckboxActionPerformed
        simulator.setPaused(!runningCheckbox.isSelected());
    }//GEN-LAST:event_runningCheckboxActionPerformed

    private void timeStepSliderVariableMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_timeStepSliderVariableMouseDragged
        double v = 0.01 * ((double)timeStepSliderVariable.getValue());
        simulator.setTimeStep( v );
        timestepTextField.setText( String.valueOf(v) );
    }//GEN-LAST:event_timeStepSliderVariableMouseDragged

    private void viscositySliderVariableMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_viscositySliderVariableMouseDragged
        double v = 0.001 * ((double)viscositySliderVariable.getValue());
        simulator.setViscosity( v );
        viscosityTextfield.setText( String.valueOf(v) );
    }//GEN-LAST:event_viscositySliderVariableMouseDragged

    private void velocityMButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_velocityMButtonActionPerformed
        VelocityRenderer.setVisible( true );
        DensityRenderer.setVisible( false );
        ForceRenderer.setVisible(false);
        DivergenceRenderer.setVisible( false );
    }//GEN-LAST:event_velocityMButtonActionPerformed

    private void densityButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_densityButtonActionPerformed
        VelocityRenderer.setVisible( false );
        DensityRenderer.setVisible( true );
        ForceRenderer.setVisible(false);
        DivergenceRenderer.setVisible( false );
    }//GEN-LAST:event_densityButtonActionPerformed

private void forceMagnitudeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forceMagnitudeButtonActionPerformed
        VelocityRenderer.setVisible( false );
        DensityRenderer.setVisible( false);
        ForceRenderer.setVisible( true );
        DivergenceRenderer.setVisible( false );
}//GEN-LAST:event_forceMagnitudeButtonActionPerformed

private void saturationSlider(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saturationSlider
    float s = (float)saturationSlider.getValue();
    saturationTextField.setText(String.valueOf(s) + "%");
    ColorMap.setSaturation((float)s);
    DensityRendererPanel.saturationSlider.setValue(saturationSlider.getValue());
    DensityRendererPanel.saturationTextField.setText(saturationTextField.getText());
    ForceRendererPanel.saturationSlider.setValue(saturationSlider.getValue());
    ForceRendererPanel.saturationTextField.setText(saturationTextField.getText());
    VelocityRendererPanel.saturationSlider.setValue(saturationSlider.getValue());
    VelocityRendererPanel.saturationTextField.setText(saturationTextField.getText());
    DivergenceRendererPanel.saturationSlider.setValue(saturationSlider.getValue());
    DivergenceRendererPanel.saturationTextField.setText(saturationTextField.getText());
    IsoLinesRendererPanel.saturationSlider.setValue(saturationSlider.getValue());
    IsoLinesRendererPanel.saturationTextField.setText(saturationTextField.getText());
}//GEN-LAST:event_saturationSlider

private void hueSlider(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_hueSlider
    float h = (float)hueSlider.getValue();
    hueTextField.setText(String.valueOf(h) +" degrees");
    ColorMap.setHue((float)h);
    DensityRendererPanel.hueSlider.setValue(hueSlider.getValue());
    DensityRendererPanel.hueTextField.setText(hueTextField.getText());
    ForceRendererPanel.hueSlider.setValue(hueSlider.getValue());
    ForceRendererPanel.hueTextField.setText(hueTextField.getText());
    VelocityRendererPanel.hueSlider.setValue(hueSlider.getValue());
    VelocityRendererPanel.hueTextField.setText(hueTextField.getText());
    DivergenceRendererPanel.hueSlider.setValue(hueSlider.getValue());
    DivergenceRendererPanel.hueTextField.setText(hueTextField.getText());
    IsoLinesRendererPanel.hueSlider.setValue(hueSlider.getValue());
    IsoLinesRendererPanel.hueTextField.setText(hueTextField.getText());
}//GEN-LAST:event_hueSlider

    private void velocityVectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_velocityVectorActionPerformed
        HedgehogRenderer.setVectorField( false );
        EllipsoidRenderer.setVectorField( false );
        ConeRenderer.setVectorField( false );
    }//GEN-LAST:event_velocityVectorActionPerformed

    private void forceVectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forceVectorActionPerformed
        HedgehogRenderer.setVectorField( true );
        EllipsoidRenderer.setVectorField( true );
        ConeRenderer.setVectorField( true );
    }//GEN-LAST:event_forceVectorActionPerformed

    private void vectorSetCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vectorSetCheckBoxActionPerformed
        if( vectorSetCheckBox.isSelected() ){
            glyphSet.setEnabled(true);
            glyphSetActionPerformed( evt );
        } else {
            HedgehogRenderer.setVisible( false );
            EllipsoidRenderer.setVisible( false );
            ConeRenderer.setVisible( false );
            glyphSet.setEnabled( false );
        }
    }//GEN-LAST:event_vectorSetCheckBoxActionPerformed

    private void glyphSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_glyphSetActionPerformed
        switch( glyphSet.getSelectedIndex() ){
            case 0: // See the HedgehogRenderer
                HedgehogRenderer.setVisible( true );
                EllipsoidRenderer.setVisible( false );
                ConeRenderer.setVisible( false );
                break;
            case 1: // See the EllipsoidRenderer
                HedgehogRenderer.setVisible( false );
                EllipsoidRenderer.setVisible( true );
                ConeRenderer.setVisible( false );
                break;
            case 2: // See the ConeRenderer
                HedgehogRenderer.setVisible( false );
                EllipsoidRenderer.setVisible( false );
                ConeRenderer.setVisible( true );
                break;
        }
    }//GEN-LAST:event_glyphSetActionPerformed

    private void divergenceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_divergenceButtonActionPerformed
        VelocityRenderer.setVisible( false );
        DensityRenderer.setVisible( false);
        ForceRenderer.setVisible( false );
        DivergenceRenderer.setVisible( true );
    }//GEN-LAST:event_divergenceButtonActionPerformed

    private void isoLinesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_isoLinesCheckBoxActionPerformed
        IsoLinesRenderer.setVisible( isoLinesCheckBox.isSelected() );
        isoline0Slider.setEnabled(isoLinesCheckBox.isSelected());            
    }//GEN-LAST:event_isoLinesCheckBoxActionPerformed

    private void isoline0SliderMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_isoline0SliderMouseDragged
        double rho = isoline0Slider.getValue()/10000d;
        IsoLinesRenderer.clearDensities();
        IsoLinesRenderer.setDensityN(rho, 0);
        rho0TextField.setText( String.valueOf(rho) );
        IsoLinesRendererPanel.isoline1Slider.setValue(isoline0Slider.getValue());
        IsoLinesRendererPanel.rho1TextField.setText( String.valueOf(rho) );
    }//GEN-LAST:event_isoline0SliderMouseDragged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup dataSetButtonGroup;
    private javax.swing.JLabel dataSetLabel;
    private javax.swing.JRadioButton densityButton;
    private javax.swing.JRadioButton divergenceButton;
    private javax.swing.JRadioButton forceMagnitude;
    private javax.swing.JRadioButton forceVector;
    private javax.swing.JComboBox glyphSet;
    private javax.swing.JLabel hueLabel;
    public static javax.swing.JSlider hueSlider;
    public static javax.swing.JTextField hueTextField;
    private javax.swing.JCheckBox isoLinesCheckBox;
    public static javax.swing.JSlider isoline0Slider;
    private javax.swing.JLabel jLabel1;
    public static javax.swing.JTextField rho0TextField;
    private javax.swing.JCheckBox runningCheckbox;
    private javax.swing.JLabel saturationLabel;
    public static javax.swing.JSlider saturationSlider;
    public static javax.swing.JTextField saturationTextField;
    private javax.swing.JLabel timeStepLabel;
    private javax.swing.JSlider timeStepSliderVariable;
    private javax.swing.JTextField timestepTextField;
    private javax.swing.JLabel vectorSet;
    private javax.swing.ButtonGroup vectorSetButtonGroup;
    private javax.swing.JCheckBox vectorSetCheckBox;
    private javax.swing.JRadioButton velocityMButton;
    private javax.swing.JRadioButton velocityVector;
    private javax.swing.JLabel viscosityLabel;
    private javax.swing.JSlider viscositySliderVariable;
    private javax.swing.JTextField viscosityTextfield;
    // End of variables declaration//GEN-END:variables

}
